package com.ruoyi.back.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.back.domain.OrdertTH;
import com.ruoyi.back.service.IOrdertTHService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 订单查询Controller
 *
 * @author ruoyi
 * @date 2022-09-24
 */
@RestController
@RequestMapping("/orderTH/ordertTH")
public class OrdertTHController extends BaseController
{
    @Autowired
    private IOrdertTHService ordertTHService;

    /**
     * 查询订单查询列表
     */
    @PreAuthorize("@ss.hasPermi('orderTH:ordertTH:list')")
    @GetMapping("/list")
    public TableDataInfo list(OrdertTH ordertTH)
    {
        startPage();
        List<OrdertTH> list = ordertTHService.selectOrdertTHList(ordertTH);
        return getDataTable(list);
    }

    /**
     * 导出订单查询列表
     */
    @PreAuthorize("@ss.hasPermi('orderTH:ordertTH:export')")
    @Log(title = "订单查询", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, OrdertTH ordertTH)
    {
        List<OrdertTH> list = ordertTHService.selectOrdertTHList(ordertTH);
        ExcelUtil<OrdertTH> util = new ExcelUtil<OrdertTH>(OrdertTH.class);
        util.exportExcel(response, list, "订单查询数据");
    }

    /**
     * 获取订单查询详细信息
     */
    @PreAuthorize("@ss.hasPermi('orderTH:ordertTH:query')")
    @GetMapping(value = "/{orderid}")
    public AjaxResult getInfo(@PathVariable("orderid") Long orderid)
    {
        return AjaxResult.success(ordertTHService.selectOrdertTHByOrderid(orderid));
    }

    /**
     * 新增订单查询
     */
    @PreAuthorize("@ss.hasPermi('orderTH:ordertTH:add')")
    @Log(title = "订单查询", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OrdertTH ordertTH)
    {
        return toAjax(ordertTHService.insertOrdertTH(ordertTH));
    }

    /**
     * 修改订单查询
     */
    @PreAuthorize("@ss.hasPermi('orderTH:ordertTH:edit')")
    @Log(title = "订单查询", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OrdertTH ordertTH)
    {
        return toAjax(ordertTHService.updateOrdertTH(ordertTH));
    }

    /**
     * 删除订单查询
     */
    @PreAuthorize("@ss.hasPermi('orderTH:ordertTH:remove')")
    @Log(title = "订单查询", businessType = BusinessType.DELETE)
	@DeleteMapping("/{orderids}")
    public AjaxResult remove(@PathVariable Long[] orderids)
    {
        return toAjax(ordertTHService.deleteOrdertTHByOrderids(orderids));
    }
}
